home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- /*________________________________________________________________________
- |
- | blixmenu.c - all the routines use for the pop-up
- |
- */
-
- #include <gl/gl.h>
- #include <gl/sphere.h>
- #include <stdio.h>
- #include <unistd.h>
- #include <strings.h>
- #include <limits.h>
-
- #include "blix.h"
- #include "blixsound.h"
- #include "blixscore.h"
- #include "blixui.h"
- #include "lod.h"
- #include "maze.h"
-
- extern int can_do_textures;
- int sginap(long ticks);
-
- static long mymenu, lodmenu, musicmenu, scoremenu, helpmenu;
-
- void dum(void) {
- ;
- }
-
- void volume_up(void) {
- volume_change(1);
- }
-
- void volume_down(void) {
- volume_change(-1);
- }
-
-
- /*_________________________________________________________________________
- |
- | do_help - display help file
- |
- | the help file is a showcase 3.0 file that uses the Honesty fun font.
- |
- */
-
- void do_help(int help) {
- FILE *f;
- char cmn[512];
- char fullpath[512];
- strcpy(fullpath, datadir);
- switch (help) {
- case 1:
- strcat(fullpath, "blix.showcase");
- break;
- case 2:
- strcat(fullpath, "blixabout.showcase");
- break;
- case 3:
- strcat(fullpath, "blixhints.showcase");
- break;
- }
- f = fopen(fullpath, "r");
- if (f != NULL) {
- fclose(f);
- /* use single buffer mode for best results on 8 bit systems */
- if (getgdesc(GD_BITS_NORM_DBL_RED) > 3) {
- strcpy(cmn,"showcase -v ");
- } else {
- strcpy(cmn,"showcase -v -b ");
- }
- strcat(cmn, fullpath);
- fprintf(stderr, "%s: starting showcase ...\n", basename);
- system(cmn);
- } else {
- fprintf(stderr, "%s: cannot locate help file %s\n", basename, fullpath);
- }
- }
-
-
- void set_music(int l) {
- if (l < 4) {
- /* start music */
- switch (l) {
- case 1:
- current_tune = SFX_TUNE_A;
- setpup(musicmenu, 1, PUP_GREY);
- setpup(musicmenu, 2, PUP_NONE);
- setpup(musicmenu, 3, PUP_NONE);
- setpup(musicmenu, 4, PUP_NONE);
- break;
- case 2:
- current_tune = SFX_TUNE_B;
- setpup(musicmenu, 1, PUP_NONE);
- setpup(musicmenu, 2, PUP_GREY);
- setpup(musicmenu, 3, PUP_NONE);
- setpup(musicmenu, 4, PUP_NONE);
- break;
- case 3:
- current_tune = SFX_TUNE_C;
- setpup(musicmenu, 1, PUP_NONE);
- setpup(musicmenu, 2, PUP_NONE);
- setpup(musicmenu, 3, PUP_GREY);
- setpup(musicmenu, 4, PUP_NONE);
- break;
- }
- if (!playing_tune) {
- toggle_tune();
- sfx(current_tune);
- playing_tune = 1;
- } else {
- toggle_tune();
- sginap(CLK_TCK/4);
- toggle_tune();
- sfx(current_tune);
- }
- } else {
- if (playing_tune) {
- toggle_tune();
- playing_tune = 0;
- setpup(musicmenu, 1, PUP_NONE);
- setpup(musicmenu, 2, PUP_NONE);
- setpup(musicmenu, 3, PUP_NONE);
- setpup(musicmenu, 4, PUP_GREY);
- }
- }
- }
-
- void showhigh(int score) {
-
- save_displaymode();
- showscore(1, score, 1);
- restore_displaymode();
- enter_redraw();
- }
-
- void do_menus(void) {
- disable_pop();
- sfx(SFX_POP);
- dopup(mymenu);
- enable_pop();
- }
-
- void pause_game(void) {
- int i;
- float v1[3];
- save_displaymode();
- display_scene = PAUSED;
- uimode = MODE2D;
- cpack(0x00000000);
- switch_single();
- clear();
- pushmatrix();
- ortho2(0,1,0,1);
- lmbind(MATERIAL, 0);
- /* fade in score display */
- for (i=16; i>=0; i--) {
- setpattern(i);
- bgnqstrip();
- v1[0] = 1; v1[1] = 0;cpack(0x000052ff);
- v2f(v1);
- v1[0] = 1; v1[1] = 1; cpack(0x000038ff);
- v2f(v1);
- v1[0] = 0; v1[1] = 0; cpack(0x000061ff);
- v2f(v1);
- v1[0] = 0; v1[1] = 1; cpack(0x000022bb);
- v2f(v1);
- gsync();
- endqstrip();
- gflush();
- sginap(CLK_TCK/50);
- }
- draw_whatever2d();
- while (do_event() == 0) {
- sginap(CLK_TCK/10);
- }
- cpack(0x000000);
- for (i=16; i>= 0; i--) {
- setpattern(i);
- gsync();
- clear();
- gflush();
- sginap(CLK_TCK/50);
- }
- sginap(CLK_TCK/2);
- popmatrix();
- display_scene = GAME;
- uimode = MODE3D;
- restore_displaymode();
- enter_redraw();
- }
-
- void do_exit() {
- tune_off();
- sginap(CLK_TCK/4);
- sfx(SFX_END);
- sginap(CLK_TCK/4);
- exit_program();
- }
-
- /*_________________________________________________________________
- |
- | start_full_menu - make the rest of the menu entries active too
- |
- */
-
- void start_full_menu(void) {
- setpup(mymenu, 2, PUP_NONE);
- setpup(mymenu, 3, PUP_NONE);
- setpup(mymenu, 4, PUP_NONE);
- setpup(mymenu, 5, PUP_NONE);
- setpup(mymenu, 6, PUP_NONE);
- }
-
-
- void init_menus(void) {
-
- lodmenu = newpup();
- addtopup(lodmenu, "Display Options %t", dum);
- addtopup(lodmenu, " 0 (flat maze) %f", set_lod);
- addtopup(lodmenu, " 1 (blocks) %f", set_lod);
- addtopup(lodmenu, " 2 (standard) %f", set_lod);
- addtopup(lodmenu, " 3 (extra light) %f", set_lod);
- addtopup(lodmenu, " 4 (textures) %f", set_lod);
- addtopup(lodmenu, " 5 (fine circles) %f", set_lod);
- if (can_do_textures == 0) {
- setpup(lodmenu, 5, PUP_GREY);
- }
- musicmenu = newpup();
- addtopup(musicmenu, "Select Instruments %t", dum);
- addtopup(musicmenu, " Bottle %f", set_music);
- addtopup(musicmenu, " Asia mix %f", set_music);
- addtopup(musicmenu, " Bellboard %f %l", set_music);
- addtopup(musicmenu, " No music %f", set_music);
- if (no_sfx) {
- setpup(musicmenu, 1, PUP_GREY);
- setpup(musicmenu, 2, PUP_GREY);
- setpup(musicmenu, 3, PUP_GREY);
- setpup(musicmenu, 4, PUP_GREY);
- } else if (notune) {
- setpup(musicmenu, 4, PUP_GREY);
- } else {
- setpup(musicmenu, 1, PUP_GREY);
- }
- scoremenu = newpup();
- addtopup(scoremenu, "Select Highscore %t", dum);
- addtopup(scoremenu, " Best Personal Scores %f", showhigh);
- addtopup(scoremenu, " Best Players on System %f", showhigh);
- addtopup(scoremenu, " Best Players Worldwide %f", showhigh);
- if (noworld) {
- setpup(scoremenu, 3, PUP_GREY);
- }
- helpmenu = newpup();
- addtopup(helpmenu, "Select Info %t", dum);
- addtopup(helpmenu, " Blix Usage %f", do_help);
- addtopup(helpmenu, " Blix Info %f", do_help);
- addtopup(helpmenu, " Blix Hints %f", do_help);
-
- mymenu = newpup();
- addtopup(mymenu, "Blix Options %t", dum);
- addtopup(mymenu, " Help %m %l", helpmenu);
- addtopup(mymenu, " Reset Transformations %f", reset_transforms);
- addtopup(mymenu, " Stop Spinning %f", stop_spin);
- addtopup(mymenu, " Pause Game %f %l", pause_game);
- addtopup(mymenu, " Level of Detail %m %l", lodmenu);
- addtopup(mymenu, " Show Highscore %m %l", scoremenu);
- addtopup(mymenu, " Sound %m", musicmenu);
- addtopup(mymenu, " Louder %f", volume_up);
- addtopup(mymenu, " Softer %f %l", volume_down);
- #ifdef BUILDNODES
- addtopup(mymenu, " Report On/Off %f", toggle_report);
- addtopup(mymenu, " Zbuffer On/Off %f %l", toggle_zbuf);
- addtopup(mymenu, " Read Maze %f %l", build_again);
- addtopup(mymenu, " Write path %f %l", write_nodes);
- #endif
- addtopup(mymenu, " Exit Program %f", do_exit);
- setpup(mymenu, 2, PUP_GREY);
- setpup(mymenu, 3, PUP_GREY);
- setpup(mymenu, 4, PUP_GREY);
- setpup(mymenu, 5, PUP_GREY);
- setpup(mymenu, 6, PUP_GREY);
- }
-